using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;

public class UnityScriptCompiling : AssetPostprocessor
{
    static string sourceFolder = "Library/ScriptAssemblies/";
    static string targetFolder = "Assets/StreamingAssets/";
    [UnityEditor.Callbacks.DidReloadScripts]
    static void AllScriptsReloaded()
    {

        if (!Directory.Exists(targetFolder))
        {
            Directory.CreateDirectory(targetFolder);
        }
        LoadAssembly(sourceFolder, targetFolder, "HotFix.dll");
        LoadAssembly(sourceFolder, targetFolder, "HotFix.pdb");
    }


    static void LoadAssembly(string sourceFolder, string targetPath,string fileName)
    {
        string path = sourceFolder + fileName;
        if (File.Exists(path))
        {
            FileInfo file = new FileInfo(path);
            file.CopyTo(targetPath+fileName, true);
        }
    }


}
